﻿<ResourceDictionary x:Class="OpenLS.Spreadsheet.UI.Internals.FontFormatterResources"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:UI="clr-namespace:OpenLS.Spreadsheet.UI" xmlns:Internals="clr-namespace:OpenLS.Spreadsheet.UI.Internals" xmlns:Spreadsheet="clr-namespace:OpenLS.Spreadsheet;assembly=OpenLS.Spreadsheet" xmlns:UI1="clr-namespace:OpenLS.Drawing.UI;assembly=OpenLS.Drawing.UI" xmlns:UI2="clr-namespace:OpenLS.UI;assembly=OpenLS.UI" xmlns:Internals1="clr-namespace:OpenLS.Drawing.UI.Internals;assembly=OpenLS.Drawing.UI"
                    xmlns:Resources="clr-namespace:OpenLS.Spreadsheet.UI.Internals.Resources">
    <ResourceDictionary.MergedDictionaries>
        <Internals:ColorResources></Internals:ColorResources>
        <UI:EnumResources/>
    </ResourceDictionary.MergedDictionaries>
    <UI:EnumValueEnumerator x:Key="ee"></UI:EnumValueEnumerator>
    <Style x:Key="labelWithColon" TargetType="{x:Type Label}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Label}">
                    <StackPanel Orientation="Horizontal">
                        <Label Content="{TemplateBinding Content}" Padding="0"/>
                        <Label Content=": " Padding="0"></Label>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <DataTemplate DataType="{x:Type UI:FontFormatter}">
        <Grid Name="self">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="80"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Label Content="{x:Static Resources:UIStringTable.Font_}" Style="{StaticResource labelWithColon}" Grid.Row="0"  Grid.Column="0"/>
            <Label Content="{x:Static Resources:UIStringTable.FontStyle_}" Style="{StaticResource labelWithColon}" Grid.Row="0"  Grid.Column="1"/>
            <Label Content="{x:Static Resources:UIStringTable.Size_}" Style="{StaticResource labelWithColon}" Grid.Row="0"  Grid.Column="2"/>

            <DockPanel Grid.Row="1"  Grid.Column="0" >
                <TextBox DockPanel.Dock="Top" Name="family" Text="{Binding FontFamily, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"/>
                <ListBox Name="familyListBox" SelectionChanged="OnFontFamilySelectionChanged"
               ItemsSource="{Binding Source={x:Static Fonts.SystemFontFamilies}}">
                </ListBox>
            </DockPanel>
            <DockPanel Grid.Row="1"  Grid.Column="2" >
                <TextBox DockPanel.Dock="Top" Name="size" Text="{Binding Size, UpdateSourceTrigger=PropertyChanged}"/>
                <ListBox Name="sizeListBox" SelectionChanged="OnSizeSelectionChanged"
               ItemsSource="{Binding Path=FontSizes}">
                    <ListBox.ItemTemplate>
                        <HierarchicalDataTemplate>
                            <TextBlock Text="{Binding}"/>
                        </HierarchicalDataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </DockPanel>
            <ListBox Grid.Row="1" Grid.Column="1" SelectionChanged="OnFontStyleSelectionChanged">
                <ListBoxItem Content="{x:Static Resources:UIStringTable.Normal}" />
                <ListBoxItem Content="{x:Static Resources:UIStringTable.Italic}" />
                <ListBoxItem Content="{x:Static Resources:UIStringTable.Bold}" />
                <ListBoxItem Content="{x:Static Resources:UIStringTable.BoldItalic}" />
            </ListBox>
            <Label Content="{x:Static Resources:UIStringTable.Underline}" Style="{StaticResource labelWithColon}" Grid.Row="3"  Grid.Column="0"/>
            <ComboBox Name="underlineCombo"  Grid.Row="4"  Grid.Column="0" ItemsSource="{Binding Source={x:Type Spreadsheet:UnderlineType}, Converter={StaticResource ee}}" 
                      SelectionChanged="OnUnderlineChanged"/>
            <Label Content="{x:Static Internals1:UIStringTable.Color_}" Style="{StaticResource labelWithColon}" Grid.Row="3"  Grid.Column="1"/>
            <ComboBox Grid.Row="4" Grid.Column="1" >
                <ComboBox.ItemsSource>
                    <Binding>
                        <Binding.Source>
                            <CollectionViewSource Source="{Binding ElementName=self, Converter={x:Static Internals:SpreadsheetConverters.StandardTextColorConverter}, Path=(UI:SpreadsheetElement.Workbook)}">
                                <!-- <CollectionViewSource.GroupDescriptions>
                                <ssui:ColorGrouping/>
                            </CollectionViewSource.GroupDescriptions> -->
                            </CollectionViewSource>

                        </Binding.Source>
                    </Binding>
                </ComboBox.ItemsSource>
            </ComboBox>

            <ComboBox Grid.Row="4" Grid.Column="1" ItemsSource="{Binding ElementName=self, Converter={x:Static Internals:SpreadsheetConverters.StandardTextColorConverter}, Path=(UI:SpreadsheetElement.Workbook)}"
                  SelectionChanged="OnFontColorChanged">
                <ComboBox.ItemTemplate>
                    <DataTemplate DataType="{x:Type Spreadsheet:SpreadsheetColor}">
                        <Rectangle Height="12"  Width="12"  Name="r">
                            <Rectangle.Fill>
                                <MultiBinding Converter="{x:Static Internals:SpreadsheetConverters.ColorToBrushConverter}">
                                    <Binding/>
                                    <Binding RelativeSource="{RelativeSource Self}" Path="(UI1:DrawingElement.ColorScheme)"/>
                                    <Binding RelativeSource="{RelativeSource Self}" Path="(UI1:DrawingElement.ColorScheme)"/>
                                </MultiBinding>
                            </Rectangle.Fill>
                        </Rectangle>
                    </DataTemplate>

                </ComboBox.ItemTemplate>
                <ComboBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel MaxWidth="180"/>
                    </ItemsPanelTemplate>
                </ComboBox.ItemsPanel>
                <ComboBox.ItemContainerStyle>
                    <Style TargetType="{x:Type ComboBoxItem}">
                        <Setter Property="Margin" Value="1"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ComboBoxItem}">
                                    <Border BorderBrush="Gray" BorderThickness="1" Name="extBorder" Margin="{TemplateBinding Margin}">
                                        <Grid>
                                            <ContentPresenter x:Name="Header" Margin="0" Width="12"
                                            VerticalAlignment="Center" ContentSource="Content" />
                                            <Border BorderBrush="Transparent" BorderThickness="1"  Name="intBorder">
                                            </Border>
                                        </Grid>
                                    </Border>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsHighlighted" Value="True">
                                            <Setter Property="Background" Value="{DynamicResource {x:Static UI2:OfficeBrushes.MenuHoverBackgroundKey}}" />
                                            <Setter Property="BorderBrush" Value="Orange" TargetName="extBorder" />
                                            <Setter Property="BorderBrush" Value="White" TargetName="intBorder" />
                                            <Setter Property="UI2:HighlightElement.IsHighlighted" Value="True"/>
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ComboBox.ItemContainerStyle>


            </ComboBox>
            <CheckBox Name="normalFontCheckBox" Content="{x:Static Resources:UIStringTable.NormalFont}"  Grid.Row="4" Grid.Column="3" IsChecked="{Binding IsNormal}"/>
            <GroupBox Header="{x:Static Resources:UIStringTable.Effects}"  Grid.Row="5" Grid.Column="0"/>
            <GroupBox Header="{x:Static Resources:UIStringTable.Preview}" Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="2">
                <Border BorderBrush="Black" BorderThickness="1" Background="White" Height="30" Width="120">
                    <TextBlock Text="AaBbCcYyZz" FontSize="{Binding Size}" 
                   FontStyle="{Binding Path=FontStyle}"
                   FontWeight ="{Binding Path=FontWeight }"
                   FontFamily="{Binding  Path=FontFamily}"/>
                </Border>
            </GroupBox>
        </Grid>
    </DataTemplate>
             
</ResourceDictionary>
